package com.liunian.algorithmstudy.greedy;


public class LemonadeChange860 {

	public boolean lemonadeChange(int[] bills) {
		int five = 0;
		int ten = 0;
		for (int i = 0; i < bills.length; i++) {
			if (bills[i] == 5) {
				five++;
			} else if (five > 0 && bills[i] == 10) {
				five--;
				ten++;
			} else {
				if (ten > 0 && five > 0) {
					ten--;
					five--;
				} else if (ten == 0 && five > 2) {
					five -= 3;
				} else {
					return false;
				}
			}
		}
		return true;
	}

}
